package com.cjq.dao;

import com.cjq.domain.User;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.jdbc.core.BeanPropertyRowMapper;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.stereotype.Repository;

import java.util.List;

@Repository
public class JdbcDao {
    @Autowired
    private JdbcTemplate jdbcTemplate;

    public List<User> findAll(){        //查询语句              //结果的映射 查询到的字段名和属性名相同的自动赋值
        return jdbcTemplate.query("select * from tb_user",new BeanPropertyRowMapper<>(User.class));
    }
}
